Skip to content

Conversation

@MC-Samuel
Copy link
Contributor

@MC-Samuel MC-Samuel commented Nov 7, 2025

Replaces #2771
Additions:

  • BlockDispenseLootScriptEvent
  • VaultChangeStateScriptEvent (Paper only)
  • VaultDisplayItemScriptEvent
  • MaterialTag.ominous for when a trial spawner or vault should be set to ominous/hard mode.
    Updates:
  • Alphabetized a couple events in the Spigot script registry
  • Modernized MaterialTag.mode and added trial spawners and vaults to it

Some of this was copied from @MrMaleficus's earlier PR, so credit to them for the events.

//
// @Location true
//
// @Triggers when a vault block state changes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be block's or block changes state.
Also . at the end.

Comment on lines +31 to +32
// <context.old_state> returns the vault state before the change.
// <context.new_state> returns the vault state after the change.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs some reference/link as to what the states are, maybe just one link in Triggers (but can also be here if you prefer)

public BlockDispenseLootScriptEvent() {
registerCouldMatcher("loot dispenses from <block>");
this.<BlockDispenseLootScriptEvent, ListTag>registerDetermination(null, ListTag.class, (evt, context, input) -> {
List<ItemStack> items = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, but can initialize to input.size().

@Override
public ObjectTag getContext(String name) {
return switch (name) {
case "item" -> item;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the same issue with the context potentially becoming outdated due to another plugin accessing it (e.g. if you - wait a bit in a script and then read it) - need to dynamically get the item here, but can keep the field for matches optimization.


public BlockDispenseLootScriptEvent() {
registerCouldMatcher("loot dispenses from <block>");
this.<BlockDispenseLootScriptEvent, ListTag>registerDetermination(null, ListTag.class, (evt, context, input) -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in general, prefixed determinations (to match their context counterparts) are usually preferred as they're easier to understand in scripts & look cleaner if the event ever gets more than one determination.

|| data instanceof Tripwire
|| (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19) && (data instanceof SculkCatalyst
|| data instanceof SculkShrieker));
|| data instanceof SculkShrieker))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space.

else if (isSculkCatalyst()) {
return ((SculkCatalyst) material.getModernData()).isBloom() ? "BLOOM" : "NORMAL"; // TODO: 1.19
else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && getBlockData() instanceof TrialSpawner trialSpawner) {
return new ElementTag(trialSpawner.getTrialSpawnerState().name(), true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use the enum constructor for these

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants